package cn.xspace.wnx.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.amap.api.services.core.PoiItem;
import com.xspace.android.xafcommon.base.BaseHolder;
import com.xspace.android.xafcommon.base.BasicAdapter;

import java.util.List;

import cn.xspace.wnx.R;

/**
 * Wubj 创建于 2017/4/7.
 */
public class MapSearchListAdapter extends BasicAdapter<PoiItem> {

    /**
     * 构造方法中传入要填充的数据
     *
     * @param mContext
     * @param mDataList 要填充的数据
     */
    public MapSearchListAdapter(Context mContext, List<PoiItem> mDataList) {
        super(mContext, mDataList);
    }

    @Override
    public BaseHolder<PoiItem> getHolder() {
        return new MapListHolder();
    }

    private class MapListHolder extends BaseHolder<PoiItem> {

        private TextView mTvTitle;
        private TextView mTvAddress;

        @Override
        protected View initHolderView() {
            View view = View.inflate(mContext, R.layout.map_search_list_item, null);
            mTvTitle = (TextView) view.findViewById(R.id.tv_map_search_item_title);
            mTvAddress = (TextView) view.findViewById(R.id.tv_map_search_item_address);
            return view;
        }

        @Override
        public void bindData(PoiItem info, int position) {
            mTvTitle.setText(info.getTitle());
            mTvAddress.setText(info.getSnippet());
        }
    }

}
